<?php
$this->pageTitle = Yii::app()->name . " - Manage $label";

$breadcrumbs = array(
	'homeLink'=>false,
	'htmlOptions'=>array('class'=>'byline'),
	'links'=>Path::createBreadcrumbsLinks($path),
);
?>

<h1>Manage <?php echo $label; ?></h1>

<?php
$this->widget('zii.widgets.CBreadcrumbs', $breadcrumbs);

$view = 'application.views';

$data = array(
	'type'=>$type,
	'path'=>$path,
	'target'=>'admin',
	'label'=>'Lokasi',
);
$this->renderPartial("$view.folder._nav", $data);

$root = Yii::app()->params['file'];
$model = new Folder("$root/$type/$path");

$config = array(
	'id'=>'object',
	'keyField'=>'basename',
	'pagination'=>false,
);
$fileDataProvider = new CArrayDataProvider($model->files, $config);
$folderDataProvider = new CArrayDataProvider($model->folders, $config);

// $data->basename in params should not be auto valued, so we cannot use double
// apostrof.
$params = 'array("path"=>"' . $path . '", "name"=>$data->basename)';
$route = "\"$type/delete\"";
$deleteUrl = 'Yii::app()->createUrl(' . $route . ', ' . $params . ')';
$route = "\"$type/rename\"";
$updateUrl = 'Yii::app()->createUrl(' . $route . ', ' . $params . ')';

$properties = array(
	'dataProvider'=>$folderDataProvider,
	'enablePagination'=>false,
	'pager'=>false,
	'id'=>'folder-list',
	'columns'=>array(
		array(
			'name'=>'basename',
			'header'=>'Sub Folder',
		),
		array(
			'class'=>'CButtonColumn',
			'updateButtonUrl'=>$updateUrl,
			'updateButtonLabel'=>'Rename/Move',
			'deleteButtonUrl'=>$deleteUrl,
			'template'=>'{update}{delete}',
		),
	),
);
$this->widget('zii.widgets.grid.CGridView', $properties);

$properties['id'] = 'file-list';
$properties['dataProvider'] = $fileDataProvider;
$properties['columns'][0]['header'] = 'filename';
$this->widget('zii.widgets.grid.CGridView', $properties);
?>

<?php
if (Yii::app()->user->hasFlash('info')) {
	$options = array(
		'align'=>'right',
		'verticalAlign'=>'top',
		'time'=>3000,
	);
	$message = Yii::app()->user->getFlash('info');
	EjQueryUiTheme::register();
	EFloatingMessage::add($message, $options);
}
?>
